package com.cea.papyrustest.uml.createcommand;

import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;

import com.cea.papyrus.core.commands.UMLElementCreateCommand;

/**
 * Test class for {@link Package} creation command
 * @author Remi Schnekenburger
 */
public class PackageCreateCommandTest extends PapyrusCommandTest {

    /**
     * Default constructor
     * @param name the name of the test case
     */
    public PackageCreateCommandTest(String name) {
	super(name);	
    }
    
    @Override
	protected void setUp() throws Exception {
	super.setUp();
	papyrusCommand= new UMLElementCreateCommand(org.eclipse.uml2.uml.Package.class,model);
    }

    /* (non-Javadoc)
     * @see com.cea.papyrustest.PapyrusCommandTest#testExecute()
     */
    @Override
	public void testExecute() {
	stack.execute(papyrusCommand);
	Element clazz=model.getPackagedElement("Package_0");
	assertNotNull("the package is created",clazz);
	assertTrue("this is not a package",((clazz)instanceof Package));
	
	stack.undo();
	assertNull("the package exist!",model.getPackagedElement("Package_0"));
	
	stack.redo();
	clazz = model.getPackagedElement("Package_0");
	assertNotNull("the package is not re-created",clazz);
	assertTrue("this is not a package",((clazz)instanceof Package));
    }
}
